package org.kotboot.service;

import org.kotboot.dao.CommodityDao;
import org.kotboot.dao.SkuDao;
import org.kotboot.domain.Commodity;
import org.kotboot.domain.Sku;
import org.kotboot.kit.K;
import org.kotboot.module.R;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * jisong.sun 2017/9/21 15:57
 */

@Service
public class CommodityDetailServ {

    @Resource
    private CommodityDao commodityDao;

    @Resource
    private SkuServ skuServ;

    public R ById(Long commodityid) {
        Commodity commodity = commodityDao.selectByPrimaryKey(commodityid);
        if(K.isNull(commodity)){
            return R.ER("不存在");
        }
        List<Sku> skuList = skuServ.byCommodityid(commodityid);
        if(K.isEmpty(skuList)){
            return R.ER("异常");
        }

        return null;
    }
}
